package com.example.java.designpattern.singleton;

import com.example.java.designpattern.Divisor;

/**
 * 懒汉式单例
 */
public class LazySingleton implements Divisor {

    private static Divisor instance;

    private LazySingleton() {
    }

    public static synchronized Divisor getInstance() {
        if (instance == null) { //有性能问题，每次访问都要同步 假如不是空的，本来可以直接返回
            instance = new LazySingleton();
        }
        return instance;
    }

    @Override
    public void divide(String target) {
    }
}
